<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <title>Home</title>
    <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no'
          name='viewport'/>
    <link rel="stylesheet" href="assets/css/bootstrap.min.css">
    <link rel="stylesheet" href="assets/css/ready.css">
    <link rel="stylesheet" href="assets/css/demo.css">
    <link rel="stylesheet" href="bootstrap/css/bootstrap.css">
    <link rel="stylesheet" href="assets/layer/layer/theme/default/layer.css"/>
    <link rel="stylesheet" href="angularjs/pagination.css">
    <script src="../homePage/js/jquery-1.9.1/jquery.js"></script>
    <script src="bootstrap/js/bootstrap.js"></script>
    <script src="layer/layer.js"></script>
    <script src="angularjs/angular.min.js"></script>
    <script src="angularjs/pagination.js"></script>
</head>
<style type="text/css">
    .main-panel {
        background-color: #FFFFFF !important;
    }

    .content {
        background-color: #FFFFFF !important;
    }
</style>

<script>
    var app = angular.module("myApp", ["pagination"]);
    app.controller("myCtrl", function ($scope, $http) {
        let admin = sessionStorage.getItem("admin");
        $scope.userid = JSON.parse(admin).userid;
        $scope.username = JSON.parse(admin).username;
        $scope.paginationConf = {
            currentPage: 1,
            itemsPerPage: 2,
            totalItems: 100,
            perPageOptions: [2, 5, 10, 20],
            onChange: function () {
                $scope.search();
            }
        };
        $scope.search = function () {
            $http.get("http://localhost:9001/report/reviewed").success(function (data) {
                $scope.list = data.data.rows;
                $scope.paginationConf.totalItems = data.data.total;
            });
        }

        $scope.dispatch = function (reportid) {
            $http.get("http://localhost:9001/report/getDispatcher").success(function (data) {
                $scope.roles = data.data;
                $scope.reportid = reportid;
                $scope.roles.unshift({userid: '0', username: '--请选择--'});
            });
            $("#myModal").modal("show");
        }

        //派遣勘察人员
        $scope.toDispatcher = function () {
            $http.get("http://localhost:9001/report/toDispatcher/" + $scope.reportid + "/" + $scope.userid).success(function (data) {
                if (data.code == 200) {
                    layer.msg(data.msg);
                    $("#myModal").modal("hide");
                    $scope.search();
                } else {
                    layer.msg(data.msg);
                }

            })

        }

    });

    function quiet() {
        sessionStorage.clear();
        window.location.href = "../adminLogin/login.html";
    }
</script>

<body ng-app="myApp" ng-controller="myCtrl" ng-init="search()">
<div class="wrapper">
    <div class="main-header">
        <div class="logo-header">
            <a href="home.html" class="logo">
                <img src="../pay/img/logo.png" style="height: 40px;width: 100px">管理中心
            </a>
            <button class="navbar-toggler sidenav-toggler ml-auto" type="button" data-toggle="collapse"
                    data-target="collapse"
                    aria-controls="sidebar" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <button class="topbar-toggler more"><i class="la la-ellipsis-v"></i></button>
        </div>
        <nav class="navbar navbar-header navbar-expand-lg float-right">
            <div class="container-fluid">
                <ul class="navbar-nav topbar-nav ml-md-auto align-items-center">


                    <li class="nav-item dropdown">
                        <a class="dropdown-toggle profile-pic" data-toggle="dropdown" href="#" aria-expanded="false">
                            <span ng-value="$scope.username">{{username}}</span>
                        </a>
                        <ul class="dropdown-menu dropdown-user">
                            <li>
                                <div class="user-box">

                                    <div class="u-text">
                                        <h4>{{username}}</h4>
                                        <p class="text-muted"></p>
                                        <a onclick="quiet()" class="btn btn-rounded btn-danger btn-sm">退出登录</a>
                                    </div>
                                </div>
                            </li>

                        </ul>
                        <!-- /.dropdown-user -->
                    </li>
                </ul>
            </div>
        </nav>
    </div>
    <div class="sidebar">
        <div class="scrollbar-inner sidebar-wrapper">
            <ul class="nav">
                <li class="nav-item active">
                    <a href="home.html">
                        <i class="la la-fonticons"></i>
                        <p>未处理报案单</p>
                        <!-- <span class="badge badge-count">5</span> -->
                    </a>
                </li>
                <li class="nav-item">
                    <a href="report.html">
                        <i class="la la-dashboard"></i>
                        <p>派遣成功报案单</p>
                        <!-- <span class="badge badge-count">5</span> -->
                    </a>
                </li>

            </ul>
        </div>
    </div>
    <div class="main-panel">
        <div class="content">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-md-12">

                        <div class="card">
                            <div class="card-header panel-info">
                                <h4 class="card-title">未处理报案单</h4>
                            </div>
                            <div class="card-body">
                                <table class="table table-bordered table-hover table-striped text-center">
                                    <tr>
                                        <td>序号</td>
                                        <td>报案号</td>
                                        <td>保单号</td>
                                        <td>报案人</td>
                                        <td>报案时间</td>
                                        <td>处理状态</td>
                                        <td>操作</td>
                                    </tr>
                                    <tr ng-repeat="l in list">
                                        <td ng-bind="$index+1"></td>
                                        <td>{{l.reportid}}</td>
                                        <td>{{l.policynum}}</td>
                                        <td>{{l.tUser.username}}</td>
                                        <td>{{l.reporttime | date:'yyyy-MM-dd'}}</td>
                                        <td>{{l.reportstate}}</td>
                                        <td>
                                            <a href="#" ng-click="dispatch(l.reportid)" class="btn btn-info">派遣勘察人员</a>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="10">
                                            <span style="height: 10px;" class="pagination pagination-centered">
                                                <tm-pagination style="position: relative;top:-31px;" conf="paginationConf"></tm-pagination>
                                            </span>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
     aria-hidden="true">
    <div class="modal-dialog">
        <form id="shopping">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title" id="myModalLabel">派遣勘察人员</h4>
                </div>
                <div class="input-group">
                    {{reportid}}
                    <label class="form-control col-sm-3">勘察人员姓名</label>
                    {{userid}}
                    <input type="hidden" ng-model="reportid">
                    <select class="form-control" ng-model="userid" ng-init="userid='0'"
                            ng-options="r.userid as r.username for r in roles">
                    </select>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <a href="#" id="setshopping" ng-click="toDispatcher()" class="btn btn-primary">确认派遣</a>
                </div>
            </div><!-- /.modal-content -->
        </form>
    </div><!-- /.modal -->
</div>
</body>
<script src="assets/js/core/jquery.3.2.1.min.js"></script>
<script src="assets/js/plugin/jquery-ui-1.12.1.custom/jquery-ui.min.js"></script>
<script src="assets/js/core/popper.min.js"></script>
<script src="assets/js/core/bootstrap.min.js"></script>
<script src="assets/js/plugin/chartist/chartist.min.js"></script>
<script src="assets/js/plugin/chartist/plugin/chartist-plugin-tooltip.min.js"></script>
<script src="assets/js/plugin/bootstrap-notify/bootstrap-notify.min.js"></script>
<script src="assets/js/plugin/bootstrap-toggle/bootstrap-toggle.min.js"></script>
<script src="assets/js/plugin/jquery-mapael/jquery.mapael.min.js"></script>
<script src="assets/js/plugin/jquery-mapael/maps/world_countries.min.js"></script>
<script src="assets/js/plugin/chart-circle/circles.min.js"></script>
<script src="assets/js/plugin/jquery-scrollbar/jquery.scrollbar.min.js"></script>
<script src="assets/js/ready.min.js"></script>
</html>
